#include "clib_system.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>

i32_t clib_get_system_info(clib_system_info_t* info)
{
    u08_t line[4096];
    u08_t key[128];
    u08_t value[128];
    i32_t len;
    FILE* fh;
    if(!info) {
        return -1;
    }

    fh = fopen("/etc/os-release","rb");
    if(!fh) {
        return -1;
    }

    len = fread(line,1,sizeof(line),fh);
    /** 系统名称 **/
    sscanf(line,"%s=%s",key,value);
    strcpy(info->sys_name,value);

    len = fread(line,1,sizeof(line),fh);
    sscanf(line,"%s=%s",key,value);
    strcpy(info->sys_version,value);

    /** TODO 初始化系统类型 **/
    
    return 0;
}